package com.atguigu.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单确认页的所有信息
 */
public class OrderConfirmVo {
    //用户收货地址信息
    @Getter @Setter
    private List<MemberAddressVo> address;

    //用户结算商品信息
    @Getter @Setter
    private List<OrderItemVo> items;

    @Getter @Setter
    private String orderToken;

    //发票...这里不做

    //优惠券信息，这里只做积分的
    @Getter @Setter
    private Integer integation;

    @Getter @Setter
    Map<Long, Boolean> stocks;

    //总共多少件商品
    public Integer getCount(){
        int count = 0;
        if(items != null){
            for (OrderItemVo item : items) {
                count += item.getCount();
            }
        }
        return count;
    }

    //订单总金额
    public BigDecimal getTotal(){
        BigDecimal total = new BigDecimal("0");
        if(items != null){
            for (OrderItemVo item : items) {
                total = total.add(item.getTotalPrice());
            }
        }
        return total;
    }

    //实付总金额
    public BigDecimal getPayTotal(){
        return getTotal();
    }
}
